import request from './http'
import socketService from './socket_sever'
interface ManRes<T> {
  code?: number
  data: T
  message?: string
}
interface ManageRes<T> {
    code?: number
    data: T[]
    message?: string
}
type PromiseRes<T> = Promise<ManageRes<T>>
type PromiseRes2<T> = Promise<ManRes<T>>
interface sellerlistRes {
  name: string,
  value: number,
}



// export const getseller = (data: adminlist):PromiseRes<adminlistRes> => request.get('/seller', { params: data })
export const getseller = ():PromiseRes<sellerlistRes> => socketService.Instance.send({
  action: 'getData',
  socketType: 'seller',
  chartName: 'seller',
  value: ''
})
export const gettrend = ():PromiseRes2<API.Welcome> => socketService.Instance.send({
  action: 'getData',
  socketType: 'trend',
  chartName: 'trend',
  value: ''
})
export const getmapdata = ():PromiseRes<API.map> => socketService.Instance.send({
  action: 'getData',
  socketType: 'map',
  chartName: 'map',
  value: ''
})
export const getrankdata = ():PromiseRes<sellerlistRes> => socketService.Instance.send({
  action: 'getData',
  socketType: 'rank',
  chartName: 'rank',
  value: ''
})

export const gethotproduct = ():PromiseRes<API.hotproduct> => socketService.Instance.send({
  action: 'getData',
  socketType: 'hotproduct',
  chartName: 'hotproduct',
  value: ''
})

export const getstock = ():PromiseRes<API.Stock> => socketService.Instance.send({
  action: 'getData',
  socketType: 'stock',
  chartName: 'stock',
  value: ''
})
// 全屏
export const getquanp = (data:string, value: boolean) => socketService.Instance.send({
  action: 'fullScreen',
  socketType: 'fullScreen',
  chartName: data,
  value: value
})
// 主题切换
export const themeChange = (value: string) => socketService.Instance.send({
  action: 'themeChange',
  socketType: 'themeChange',
  chartName: '',
  value: value
})